package com.example.restatr.Atcivity.LogisticsQuery;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.viewpager.widget.ViewPager;

import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.restatr.Atcivity.Main.MainActivity;
import com.example.restatr.Bean.CardBean;
import com.example.restatr.R;
import com.example.restatr.Tools;
import com.youth.banner.Banner;

import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

public class LogisticsQueryAt extends AppCompatActivity {
    private Toolbar toolbar;
    private TextView barTitle;
    private EditText search;
    private Banner rbt;
    private GridView gv;
    private List<CardBean> cardBeans = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_logistics_query_at);

        toolbar = findViewById(R.id.toolbar);
        barTitle = findViewById(R.id.bar_Title);
        search = findViewById(R.id.search);
        rbt = findViewById(R.id.banner);
        gv = findViewById(R.id.gv);
        Tools.SetBarTitle(toolbar, barTitle, "物流查询", search, this, true);
        Menu menu = toolbar.getMenu();
        menu.removeItem(R.id.item2);
        menu.getItem(0).setTitle("投诉记录");
        toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                startActivity(new Intent(LogisticsQueryAt.this, MyComplaintsListAt.class));
                return true;
            }
        });
        Tools.SetBanner("/prod-api/api/logistics-inquiry/ad-banner/list", MainActivity.sp.getString("token", ""),
                "data", "imgUrl",rbt,this);
        Tools.SetCard("/prod-api/api/logistics-inquiry/logistics_company/list", MainActivity.sp.getString("token", ""),
                "url", "data", "id", "imgUrl", "name", this,
                cardBeans, gv);
        gv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(LogisticsQueryAt.this, LogisticsCompanyAt.class);
                intent.putExtra("title", cardBeans.get(position).getTitle());
                intent.putExtra("id", cardBeans.get(position).getId());
                startActivity(intent);
            }
        });
    }
}